//
//  SJHomeHeaderView.m
//  YYPHSpeedJump
//
//  Created by sujiang on 16/3/4.
//  Copyright © 2016年 sujiang. All rights reserved.
//

#import "SJHomeHeaderView.h"

@interface SJHomeHeaderView ()

@property (nonatomic, strong) NSArray *images;
@property (nonatomic, strong) NSArray *titles;

@end

@implementation SJHomeHeaderView

- (NSArray *)images
{
    return @[@"history", @"derection", @"intergral"];
}

- (NSArray *)titles
{
    return @[@"速降历史", @"新手指南", @"积分任务"];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self == [super initWithFrame:frame]) {
        [self addSubviews];
    }
    return self;
}

- (void)addSubviews
{
    self.cycScroll = [[SDCycleScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 161)];
    self.cycScroll.autoScrollTimeInterval = 5.0f;
    self.cycScroll.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
    self.cycScroll.dotColor = [UIColor whiteColor]; // 自定义分页控件小圆标颜色
    [self addSubview:self.cycScroll];
    self.cycScroll.placeholderImage = [UIImage imageNamed:@"tu-da"];
    self.cycScroll.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
    [self creatBottomView];
}

- (void)creatBottomView
{
    for (int i = 0; i < 3; i++) {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake((kScreenWidth / 3) * i, self.cycScroll.bottom, kScreenWidth / 3, 91)];
        [self addSubview:view];
        UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
        button.frame = CGRectMake((view.width - 46) / 2, 10, 46, 46);
        [view addSubview:button];
        button.tag = 10 + i;
        [button setBackgroundImage:[UIImage imageNamed:self.images[i]] forState:(UIControlStateNormal)];
        UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(button.left - 1, button.bottom + 6, 48, 14)];
        title.textColor = kColors(102, 102, 102, 1);
        title.font = [UIFont systemFontOfSize:12.0f];
        title.text = self.titles[i];
        [view addSubview:title];
    }
    self.historyBtn = (UIButton *)[self viewWithTag:10];
    self.direction = (UIButton *)[self viewWithTag:11];
    self.intergral = (UIButton *)[self viewWithTag:12];
}




@end
